HTS_LOG(opt,LOG_DEBUG); fprintf(opt->log,"File '%s' has been renamed since last mirror to '%s' ; applying changes"LF, previous_save, save); test_flush;
}
} else {
if ((opt->debug>0) && (opt->log!=NULL)) {
HTS_LOG(opt,LOG_ERROR); fprintf(opt->log,"Could not rename '%s' to '%s' ; will have to retransfer it"LF, previous_save, save); test_flush;
}
}
}
}
if (!found) {
#if HTS_FAST_CACHE
hash_pos_return=0;
#else
a=NULL;
#endif
// dΘvalider car non prΘsent sur disque dans structure originale!!!
// sinon, le fichier est ok α priori, mais on renverra un if-modified-since pour
// en Ωtre s√r
if (opt->norecatch) { // tester norecatch
if (!fexist(fconv(catbuff,save))) { // fichier existe pas mais dΘclarΘ: on l'a effacΘ
FILE* fp=fopen(fconv(catbuff,save),"wb");
if (fp) fclose(fp);
if (opt->log!=NULL) {
HTS_LOG(opt,LOG_WARNING); fprintf(opt->log,"File must have been erased by user, ignoring: %s%s"LF,back[p].url_adr,back[p].url_fil); test_flush;
}
}
}
}
} // fsize() <= 0
}
}
}
//
} else
#if HTS_FAST_CACHE
hash_pos_return=0;
#else
a=NULL;
#endif
// Existe pas en cache, ou bien pas de cache prΘsent
#if HTS_FAST_CACHE
if (hash_pos_return) { // OK existe en cache (et donnΘes aussi)!
#else
if (a!=NULL) { // OK existe en cache (et donnΘes aussi)!
#endif
if (cache->type==1) { // cache prioritaire (pas de test if-modified..)
// dans ce cas on peut Θgalement lire des rΘponses cachΘes comme 404,302...
/* MANDATORY if we don't want back_fill() to endlessly put the same file on download! */
{
int index = hash_read(opt->hash,back[i].url_sav,"",0,opt->urlhack); // lecture type 0 (sav)
if (index >= 0) {
opt->hash->liens[index]->pass2 = -1; /* DONE! */
} else {
if (opt->log != NULL) {
HTS_LOG(opt,LOG_INFO); fprintf(opt->log,"engine: warning: entry cleaned up, but no trace on heap: %s%s (%s)"LF,back[i].url_adr, back[i].url_fil,back[i].url_sav);
test_flush;
}
}
}
HTS_STAT.stat_background++;
if ((opt->debug>0) && (opt->log!=NULL)) {
HTS_LOG(opt,LOG_INFO); fprintf(opt->log,"File successfully written in background: %s"LF,back[i].url_sav); test_flush;
}
back_maydelete(opt,cache,sback,i); // May delete backing entry
} else {
if (!back[i].finalized) {
if (1) {
/* Ensure deleted or recycled socket */
/* BUT DO NOT YET WIPE back[i].r.adr */
if ( (opt->debug>1) && (opt->log!=NULL) ) {
HTS_LOG(opt,LOG_DEBUG); fprintf(opt->log,"file %s%s validated (cached, left in memory)"LF,back[i].url_adr,back[i].url_fil); test_flush;
}
back_maydeletehttp(opt, cache, sback, i);
} else {
/*
NOT YET HANDLED CORRECTLY (READ IN NEW CACHE TO DO)
*/
/* Lock the entry but do not keep the html data in memory (in cache) */
// transform 406 into 200 ; we'll catch embedded links inside the choice page
if (back[i].r.statuscode==406) { // 'Not Acceptable'
back[i].r.statuscode=HTTP_OK;
}
// 'do not erase already downloaded file'
// on an updated file
// with an error : consider a 304 error
if (!opt->delete_old) {
if (HTTP_IS_ERROR(back[i].r.statuscode) && back[i].is_update && !back[i].testmode) {
if (back[i].url_sav[0] && fexist(back[i].url_sav)) {
if ((opt->debug>1) && (opt->log!=NULL)) {
HTS_LOG(opt,LOG_DEBUG); fprintf(opt->log,"Error ignored %d (%s) because of 'no purge' option for %s%s"LF,back[i].r.statuscode,back[i].r.msg,back[i].url_adr,back[i].url_fil); test_flush;
HTS_LOG(opt,LOG_WARNING); fprintf(opt->log,"File seems complete (same size), but there was a cache read error: %s%s"LF,back[i].url_adr,back[i].url_fil); test_flush;
}
}
if (r.adr) {
freet(r.adr);
r.adr = NULL;
}
}
}
}
// Various hacks to limit re-transfers when updating a mirror
// Detect already downloaded file (with another browser, for example)
if (opt->sizehack) {
if (!back[i].is_update) { // mise α jour
if (back[i].r.statuscode==HTTP_OK && !back[i].testmode) { // 'OK'
if (!is_hypertext_mime(opt,back[i].r.contenttype, back[i].url_fil)) { // not HTML
if (strnotempty(back[i].url_sav)) { // target found